Home

Operator Usage

Name

stransitive

Description

stransitive[op, max-steps] input-seq
Implements operators that are transitive, but uses sequences instead of superpositions
max-steps is the max number of steps until the transitiveness "wears" off.
Unlike transitive[op], max-steps is mandatory for stransitive[]
as there is no clean way to determine if we are stuck in a loop
Note that if the relation is "fuzzy" then stransitive[] respects that too.
Also, the result can potentially grow exponentially with each step,
so if that is possible in your use case, set max-steps to something managable.
For example, stransitive[links-to, 4] |starting web page>
could grow large very rapidly.


Examples

-- if we load the family-tree.sw3 and family-relations.sw3 data-sets:
-- we can use stransitive[] to explore the matriarchal or patriarchal lines:
stransitive[mother, 5] |sally>
    |trude> . |sara>

stransitive[father, 5] |sally>
    |tom> . |mike> . |mark>

-- then we could see their ages all at once:
age stransitive[mother, 5] |sally>
    |38> . |56>

age stransitive[father, 5] |sally>
    |40> . |60> . |78>

-- Or, if we had the data, the changes in family name:
last-name stransitive[mother, 5] |sally>
last-name stransitive[father, 5] |sally>

-- Or, we could explore parents, grand-parents, great-grand-parents and so on:
stransitive[parent, 5] |sally>
    |trude> + |tom> . |sara> + |sam> + |ruth> + |mike> . |gina> + |mary> + |mark>

age stransitive[parent, 5] |sally>
    |38> + |40> . 2|56> + |57> + |60> . 2|76> + |78>

-- finally, a fuzzy transitive example:
is-a |A> => 0.8 |B>
is-a |B> => 0.5 |C>
is-a |C> => 0.9 |D>
is-a |D> => 0.2 |E>

-- so we can conclude:
stransitive[is-a, 10] |A>
    0.800000|B> . 0.400000|C> . 0.360000|D> . 0.072000|E>


See also

transitive transitive-operators.sw4, family-tree.sw3, family-relations.sw3

Operator type

sequence compound context